package com.niiwoo.civet.user.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author: wuke
 * @Description:
 * @Date: Created in 10:56 2017/11/18
 */
public class UserPersonalEnum {

    /**
     * 学历层次枚举
     */
    @AllArgsConstructor
    @Getter
    public enum UserEduLevelEnum {
        NO((byte)0,"无",TianChengUserPersonalEnum.UserEduLevelEnum.NO),
        SPECIAL_SCHOOL((byte)1,"中专及以下",TianChengUserPersonalEnum.UserEduLevelEnum.SPECIAL_SCHOOL),
        JUNIOR_COLLEGE((byte)2,"大专",TianChengUserPersonalEnum.UserEduLevelEnum.JUNIOR_COLLEGE),
        UNDERGRADUATE((byte)3,"本科",TianChengUserPersonalEnum.UserEduLevelEnum.UNDERGRADUATE),
        MASTER((byte)4,"研究生",TianChengUserPersonalEnum.UserEduLevelEnum.MASTER),
        DOCTOR((byte)5,"博士及以上",TianChengUserPersonalEnum.UserEduLevelEnum.DOCTOR);

        private Byte type;
        private String desc;
        private TianChengUserPersonalEnum.UserEduLevelEnum tianChengUserEduLevelEnum;

        public static UserEduLevelEnum getByLevel(byte level) {
            Optional<UserEduLevelEnum> eduLevel = Arrays.stream(values()).filter(value -> value.getType() == level).findFirst();
            return eduLevel.isPresent() ? eduLevel.get() : null;
        }
    }

    /**
     * 学历认证状态枚举：0未认证，1已认证
     */
    @AllArgsConstructor
    @Getter
    public enum EducationAuthStatusEnum {
        NO_AUTH((byte)0,"未认证"),
        AUTH((byte)1,"已认证");

        private Byte status;
        private String desc;

        public static EducationAuthStatusEnum getByLevel(byte level) {
            Optional<EducationAuthStatusEnum> eduLevel = Arrays.stream(values()).filter(value -> value.getStatus() == level).findFirst();
            return eduLevel.isPresent() ? eduLevel.get() : null;
        }
    }

    /**
     * 婚姻状况枚举（0-其他，1-未婚，2-已婚，3-离异）
     */
    @AllArgsConstructor
    @Getter
    public enum UserMaritalStatusEnum {
        UNMARRIED((byte)1,"未婚",TianChengUserPersonalEnum.UserMaritalStatusEnum.UNMARRIED),
        MARRIED((byte)2,"已婚",TianChengUserPersonalEnum.UserMaritalStatusEnum.MARRIED),
        DIVORCE((byte)3,"离异",TianChengUserPersonalEnum.UserMaritalStatusEnum.DIVORCE),
        OTHER((byte)0,"其他",TianChengUserPersonalEnum.UserMaritalStatusEnum.OTHER);

        private Byte status;
        private String desc;
        private TianChengUserPersonalEnum.UserMaritalStatusEnum tianChengUserMaritalStatusEnum;

        public static UserMaritalStatusEnum getByLevel(byte level) {
            Optional<UserMaritalStatusEnum> eduLevel = Arrays.stream(values()).filter(value -> value.getStatus() == level).findFirst();
            return eduLevel.isPresent() ? eduLevel.get() : null;
        }
    }

    /**
     * 学历是否允许更新枚举（0-不允许，1-允许）
     */
    @AllArgsConstructor
    @Getter
    public enum EduIsAllowUpdateEnum {
        NO_ALLOW((byte)0,"不允许"),
        ALLOW((byte)1,"允许");

        private Byte type;
        private String desc;

        public static EduIsAllowUpdateEnum getByType(byte type) {
            Optional<EduIsAllowUpdateEnum> eduLevel = Arrays.stream(values()).filter(value -> value.getType() == type).findFirst();
            return eduLevel.isPresent() ? eduLevel.get() : null;
        }
    }

}
